{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fzIWxg0GIv42"
      },
      "source": [
        "# ModelScope AgentFabric 使用教程\n",
        "\n",
        "克隆代码"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "C_jkwJFH645E",
        "outputId": "b108fcad-18dc-4263-8e15-3450a33098f1"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Cloning into 'modelscope-agent'...\n",
            "remote: Enumerating objects: 1879, done.\u001b[K\n",
            "remote: Counting objects: 100% (735/735), done.\u001b[K\n",
            "remote: Compressing objects: 100% (327/327), done.\u001b[K\n",
            "remote: Total 1879 (delta 481), reused 575 (delta 406), pack-reused 1144\u001b[K\n",
            "Receiving objects: 100% (1879/1879), 25.66 MiB | 23.52 MiB/s, done.\n",
            "Resolving deltas: 100% (1132/1132), done.\n"
          ]
        }
      ],
      "source": [
        "!git clone https://github.com/modelscope/modelscope-agent.git"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "u-1gX1YY8xmr"
      },
      "outputs": [],
      "source": [
        "!cd modelscope-agent && pip install -r requirements.txt && pip install -r apps/agentfabric/requirements.txt"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "id": "0SejT3AH9cF4"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "os.chdir('modelscope-agent/apps/agentfabric')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "id": "5yyNZrVv98uu"
      },
      "outputs": [],
      "source": [
        "import sys\n",
        "sys.path.append('../../')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "LxxhrU7M_cFe"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "\n",
        "\n",
        "# Dashscope API KEY\n",
        "print('请输入Dashscope API KEY，可以从这里获取: https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key')\n",
        "os.environ['DASHSCOPE_API_KEY'] = input()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kg8lF49LMtoo"
      },
      "source": [
        "启动应用"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "x6ToFHY9-AsI",
        "outputId": "c5c226b6-b8d7-4e55-af1e-513692512663"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "^C\n"
          ]
        }
      ],
      "source": [
        "! sed -i 's#demo.launch()#demo.launch(share=True)#g' app.py && export PYTHONPATH=$PYTHONPATH:/content/modelscope-agent && python app.py"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
